#include "NFARule.h"
#include <iostream>
#include <fstream>
#include <istream>
#include <ctype.h>
#include <vector>
#include <string>

const int MAX_SYM_PER_LINE = 16;

NFARule get_rule_from_stream(std::istream& in)
{
    std::vector<char> rule;
    string str;
    getline(in, str);
    
    for( int i = 0; i != str.size(); ++i )
    { 
        if ( isalpha(str[i]) ) 
            rule.push_back( str[i] );    
    }
 
    NFARule n(0, 0, 0);    
    switch (rule.size())
    {
        case 3:
            n = NFARule(rule[0], rule[1], rule[2]);
            break; 
        case 2:
            if ( isupper(rule[1]) )
                n = NFARule(rule[0], 0, rule[1]);
            else
                n = NFARule(rule[0], rule[1], 0);   
            break;
        case 1:
            n = NFARule(rule[0], 0, 0);
            break; 
    }
    
    return n;
}


void example()
{
    std::ifstream in("NFARules.txt");
    NFARule n = get_rule_from_stream( std::cin );  
    std::cout << n.toString() << std::endl;
}
